package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.market.entity.LotteryType;
import com.jic.market.mapper.LotteryTypeMapper;
import com.jic.market.service.LotteryTypeService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 抽奖活动规则关联表
 * @author : 
 * @email : 
 * @since : 2020-03-03 03:06:55
 * @version : v1.0.0
 */
@Service
public class LotteryTypeServiceImpl implements LotteryTypeService{

    @Autowired
    private LotteryTypeMapper lotteryTypeMapper;

    @Override
    public long insert(LotteryType lotteryType) {
        long flag = lotteryTypeMapper.insert(lotteryType);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return lotteryTypeMapper.delete(id);
    }

    @Override
    public long update(LotteryType lotteryType) {
        return lotteryTypeMapper.update(lotteryType);
    }

    @Override
    public LotteryType queryByPrimaryKey(Long id){
        return lotteryTypeMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<LotteryType> query(LotteryType lotteryType){
        return lotteryTypeMapper.query(lotteryType);
    }

    @Override
    public PageResult<LotteryType> queryPage(LotteryType lotteryType, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<LotteryType> list = lotteryTypeMapper.queryPage(startIndex, pageQuery.getLimit(), lotteryType);
        long count = lotteryTypeMapper.queryPageCount(lotteryType);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}